<?php
$profileId=$_SESSION['profileid'];
if(isset($_GET['date3']))
{
	$startDate = $_GET['date3'];
} else {
	$tanggalmulai= date('Y-m-d', strtotime('-1 month'));
	$startDate = $tanggalmulai;
}
if(isset($_GET['date4']))
{
	$endDate = $_GET['date4'];
} else {
$endDate = date('Y-m-d');
}
if(isset($_GET['dimension']))
{
	$dimension = $_GET['dimension'];
} else {
$dimension = "ga:date";
}
?>
<h2 align = "center">Ad Impression</h2>
<div class = "row" >
<?php
$ADParams = array(
      'dimensions' => 'ga:adGroup',
      
      
		);
$resultsAD = $analytics->data_ga->get(
       'ga:' . $profileId,
       $startDate,
       $endDate,
	   'ga:impressions',
       $ADParams
	   );
	   

 ?>
<script type="text/javascript">
        var chartDataAD = [
		<?php
    // Print table rows.
		$x=1;
		foreach ($resultsAD->getRows() as $row) {
      
		?>
                {
                    "Grup Iklan": "<?php echo $row[0]; ?>",
                    "Impression": <?php echo $row[1]; ?>
                }
		<?php
		if($x>=sizeof($resultsAD->getRows()))
		{
		?>
		<?php
		}
		else
		{
		?>
		,
		<?php
		}
		$x++;
     
		}
?>
        ];
</script>	
</div>

      

        <script type="text/javascript">
            var chartAD;

            AmCharts.ready(function () {
                // PIE CHART
                chartAD = new AmCharts.AmPieChart();
                chartAD.dataProvider = chartDataAD;
                chartAD.titleField = "Grup Iklan";
                chartAD.valueField = "Impression";
                chartAD.outlineColor = "#FFFFFF";
                chartAD.outlineAlpha = 0.8;
                chartAD.outlineThickness = 2;
                chartAD.balloonText = "";
                // this makes the chartAD 3D
                chartAD.depth3D = 15;
                chartAD.angle = 30;

                // WRITE
                chartAD.write("chartAD");
            });
        </script>

<div class = "row" >

<div id="chartAD" style="width: 100% ; height: 400px;"></div>
</div>







